/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import bdd.DBLink;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author elbeigni
 */
public class ListePromoEns {
  private DBLink dblink;
  List<Promotion> listePromoEns;

  public ListePromoEns() {
      dblink = new DBLink();
      listePromoEns = new ArrayList<Promotion>();
  }

  public ListePromoEns(List<Promotion> listePromoEns) {
      dblink = new DBLink();
      this.listePromoEns = listePromoEns;
  }

  public List<Promotion> getListePromoEns() {
    return listePromoEns;
  }

  public void setListePromoEns(List<Promotion> listePromo) {
    this.listePromoEns = listePromo;
  }

  public void add(Promotion promo) {
    this.listePromoEns.add(promo);
  }

  public void recupererListePromoEns(){
       int numPromo;
      try
      {
            DBLink db = new DBLink();
            db.connexion();
            PreparedStatement pst = db.getConnection().prepareStatement("select distinct cr.numpromotion from creneau cr where cr.numenseignant= 2");
            db.setPst(pst);
            ResultSet rs = db.getPst().executeQuery();
            db.setRs(rs);
            while(db.getRs().next())
            {   numPromo = rs.getInt("numpromotion");
                Promotion p=new Promotion();
                p.setNumPromotion(db.getRs().getInt("numpromotion"));
                this.listePromoEns.add(p);
            }
            db.getConnection().close();
      }
      catch (SQLException ex)
      {
            Logger.getLogger(ListeECEns.class.getName()).log(Level.SEVERE, null, ex);
      }
  }
}
